using System.Threading.Tasks;

namespace Puppy.DynamicProxy
{
    public class SimpleAsyncInterceptor : PuppyInterceptor
    {
        public async override Task InterceptAsync(IPuppyMethodInvocation invocation)
        {
            await Task.Delay(5);
            (invocation.TargetObject as ICanLogOnObject)?.Logs?.Add($"{GetType().Name}_InterceptAsync_BeforeInvocation");
            await invocation.ProceedAsync();
            (invocation.TargetObject as ICanLogOnObject)?.Logs?.Add($"{GetType().Name}_InterceptAsync_AfterInvocation");
            await Task.Delay(5);
        }
    }
}
